Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Conversation

@Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented Apr 17, 2018

This PR:

  1. Add GCE metadata containerd-env. We can pass environment variables to cluster/configure.sh via containerd-env now.
  2. Parse kube-env. We can get kubernetes environment variables from kube-env.
  3. Consolidate test/configure.sh and cluster/gce/configure.sh.
  4. Add preload support.
  5. Add kubernetes environment variable NETWORK_POLICY_PROVIDER support.

Signed-off-by: Lantao Liu [email protected]

@Random-Liu
Copy link
Member Author

/test pull-cri-containerd-node-e2e

2 similar comments
@yujuhong
Copy link
Member

/test pull-cri-containerd-node-e2e

@yujuhong
Copy link
Member

/test pull-cri-containerd-node-e2e

@Random-Liu
Copy link
Member Author

/test pull-cri-containerd-build

local -r tmp_env="/tmp/${env_name}.yaml"
tmp_env_content=$(fetch_metadata "${env_name}")
if [ -z "${tmp_env_content}" ]; then
echo "No environment variable is specified in ${env_name}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This might be more clear: Environment variable ${env_name} is not set

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually ${env_name} is the name of the env file. I'll make the name less misleading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Changed to env_file_name and tmp_env_file.

fetch_env() {
local -r env_name=$1
(
umask 700;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 700?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from kubernetes code. It seems to be changed recently.
kubernetes/kubernetes#62301

Copy link
Member Author

@Random-Liu Random-Liu Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 077

)
}

# is_preloaded checks whether containerd is preloaded in the image.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The function seems generic. Change to whether a package has been preloaded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

deploy_path=${CONTAINERD_DEPLOY_PATH:-"cri-containerd-release"}
# CONTAINERD_VERSION is the cri-containerd version to use.
version=${CONTAINERD_VERSION:-""}
if [ -z "${version}" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Why not just check CONTAINERD_VERSION?
if [ -z "${CONTAINERD_VERSION}" ]; then

Copy link
Member Author

@Random-Liu Random-Liu Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need :-"" because the env may not be set.
We need version, because we'll use it later anyway.

exit 1
pkg_prefix=${CONTAINERD_PKG_PREFIX:-"cri-containerd-cni"}
# Behave differently for test and production.
if [ "${CONTAINERD_TEST:-"false"}" != "true" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified this code path in a non-test cluster? :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, actually I only verified the non-test code path. I'll rely on the test-infra to verify the test code path, e.g. the presubmit test has verified node e2e works. :)

mkdir -p $(dirname ${config_path})
cni_bin_dir="${CONTAINERD_HOME}/opt/cni/bin"
cni_template_path="${CONTAINERD_HOME}/opt/containerd/cluster/gce/cni.template"
network_policy_provider="${NETWORK_POLICY_PROVIDER:-"none"}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is NETWORK_POLICY_PROVIDER set in kube-env?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is from kube-env. Will add comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

cni_bin_dir="${CONTAINERD_HOME}/opt/cni/bin"
cni_template_path="${CONTAINERD_HOME}/opt/containerd/cluster/gce/cni.template"
network_policy_provider="${NETWORK_POLICY_PROVIDER:-"none"}"
if [ -n "${network_policy_provider}" ] && [ "${network_policy_provider}" != "none" ] && [ "${KUBERNETES_MASTER:-}" != "true" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why excluding KUBERNETES_MASTER?

Copy link
Member Author

@Random-Liu Random-Liu Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't run calico on master. We use kubenet for dockershim, and we use cni template for containerd.

@Random-Liu
Copy link
Member Author

@yujuhong Addressed comments.

@yujuhong
Copy link
Member

/lgtm

@Random-Liu Random-Liu force-pushed the improve-gce-bootstrap branch from fbb7e8a to d1ba950 Compare April 18, 2018 20:34
@k8s-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Apr 18, 2018
@Random-Liu
Copy link
Member Author

Just squash the "Address comments" commit, reapply the lgtm label.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants